"""
给定两个点，再挖掉一个圆，问两点之间的最短距离
线段，或者是两个切线段加一段圆弧
"""
from collections import Counter
from math import acos, sqrt, atan
import sys
sys.setrecursionlimit(10**6)


EPS = 1E-9


def sgn(x):
    if x > EPS:
        return 1
    return -1 if x < -EPS else 0


def myacos(x):
    if x>1:
        x = 1
    elif x<-1:
        x = -1
    return acos(x)


def dist2(x, y):
    return x*x+y*y


if __name__ == '__main__':
    # sys.stdin = open('1.std.in', 'r')
    x1, y1, x2, y2 = list(map(float, input().split()))
    x3, y3, r = list(map(float, input().split()))
    x1 -= x3
    x2 -= x3
    y1 -= y3
    y2 -= y3
    r2 = r * r
    ss = dist2(x1, y1)
    tt = dist2(x2, y2)
    d2 = dist2(x1-x2, y1-y2)
    theta = myacos((ss+tt-d2)/(2.0*sqrt(ss)*sqrt(tt)))
    sqq = sqrt(ss-r2)
    tqq = sqrt(tt-r2)
    stheta = atan(sqq/r)
    ttheta = atan(tqq/r)
    cha = theta - stheta - ttheta
    t = sgn(cha)
    if t <= 0:
        print('%.6f' % sqrt(d2))
    else:
        print('%.6f' % (sqq+tqq+r*cha))




